
package com.shai.wool.common;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import com.shai.wool.config.ConfigUtils;
import com.shai.wool.sensitiveword.SensitiveWordUtils;

/**
 * 配置初始化
 *
 * @author 朱国军
 * @since 1.0
 * @version 2016年1月4日 朱国军
 */
@Component("instantiationConfig")
public class InstantiationConfig implements ApplicationListener<ContextRefreshedEvent> {
    
    private Logger logger = LoggerFactory.getLogger(InstantiationConfig.class);

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        if (!event.getApplicationContext().getDisplayName().equals("Root WebApplicationContext")) {
            ConfigUtils.initConfig();
            logger.info("成功加载系统配置到内存中");
            SensitiveWordUtils.initSensitiveWord();
            logger.info("成功加载敏感词配置到内存中");
        }
    }
}
